# The module Element, includes all the page elements (icons, links, buttons,text_fields, checkboxes, select lists, dialog-boxes)
module Element
    @@form2='LeadCreateEditForm'
    class QuickCreateContact
        def self.fname_text_field
            return $ie.text_field(:name,$popform+".First Name")
        end
        def self.mname_text_field
            return $ie.text_field(:name,$popform+".Middle Name")
        end
        def self.lname_text_field
            return $ie.text_field(:name,$popform+".Last Name")
        end
        def self.account_select_icon
            return $ie.image(:class=>"popup",:index=>5)
        end
        def self.lead_source_select_list
            return $ie.select_list(:name,$popform+".Lead Source")
        end
        def self.save_button
            return $ie.button(:id,"SaveID")
        end
    end
    class FrmSearch_Contacts
        @@form2="frmSearch.searchCriteria"
        def self.ctrlname_select_list
            return $ie.select_list(:id,@@form2 + ".CtrlName1")
        end
        def self.condition_select_list
            return $ie.select_list(:id,@@form2 + ".Condition1")
        end
        def self.condition_value_text_field
            return $ie.text_field(:id,@@form2 + ".Condition Value1")
        end
        def self.go_button
            return $ie.button(:id,"QuickFilterGo")
        end
        def self.selection(n)
            return $ie.link(:text=>"Select",:index=>n)
        end
        def self.contact_selection(name)
            $ie = Watir::IE.attach(:title,/Search/)
            Element::FrmSearch_Contacts.condition_value_text_field.set(name)
            sleep 5
            Element::FrmSearch_Contacts.go_button.click
            sleep 5
            count = 0
            for i in 1..100
                if Element::FrmSearch_Contacts.selection(i).exist?
                    count+=1
                    i+=1
                else
                    break
                    return count
                end
            end
            return rand(count)+1
        end
    end
end